<template>
	<view class="content">
		<image class="logo" src="/static/icon/scan.png" v-on:click="onClick"></image>
		<button type="default" v-on:click="onClick">扫码查看</button>
		<view class="text-area">
			<text class="scanresult">{{scanresult}}</text>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				scanresult: '扫码获得的内容将显示在这里',
				username: '',
				headimg: ''
			}
		},
		onLoad() {

			uni.login({
				success: (loginres) => {
					console.log(loginres.authResult)
				},
				fail: (res) => {

				}
			})
		},
		methods: {
			onClick: function() {
				uni.scanCode({
					success: (res) => {
						console.log("success")
						console.log(res.result)
						this.scanresult = res.result

					},
					complete: (res) => {
						console.log("complete")
						console.log(res.result)
					},
					fail: (res) => {
						this.scanresult = "扫码失败"
					}
				})
			},

		}
	}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
		top: 10;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}
</style>
